package org.dothwinds.serviceprovider;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@RestController
public class SpringCloudStudyServiceProviderApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringCloudStudyServiceProviderApplication.class, args);
	}

	@Autowired
	private RestTemplate restTemplate;

	@Bean
	public RestTemplate getRestTemplate(){
		return new RestTemplate();
	}

	@GetMapping("/sayHi")
	public String sayHi() {
		return restTemplate.getForObject("http://localhost:9002/sayHi", String.class);
	}

}
